/**
 * 
 */
package uk.ac.manchester.tewpl.iceiface.client.model;

import java.util.HashSet;
import java.util.Set;

import com.extjs.gxt.ui.client.data.BaseModelData;
import com.google.gwt.user.client.rpc.IsSerializable;

/**
 * @author roland
 * 
 */
public class KBInfoModel extends BaseModelData implements IsSerializable {
	/**
	 * 
	 */
	private static final long serialVersionUID = -6244647530480930518L;
	public static final String ID = "id";
	public static final String URI = "uri";
	public static final String NAME = "name";
	public static final String DESCRIPTION = "description";
	public static final String WORKSPACES = "communities";

	public KBInfoModel() {
		set(WORKSPACES, new HashSet<KBWorkspaceModel>());
	}

	public void addWorkspace(KBWorkspaceModel workspace) {
		getWorkspaces().add(workspace);
	}

	public Set<KBWorkspaceModel> getWorkspaces() {
		return get(WORKSPACES);
	}

	public String getDescription() {
		return get(DESCRIPTION);
	}

	public Long getId() {
		return get(ID);
	}

	public String getName() {
		return get(NAME);
	}

	public String getUri() {
		return get(URI);
	}

	public void setWorkspaces(Set<KBWorkspaceModel> workspaces) {
		set(WORKSPACES, workspaces);
	}

	public void setDescription(String description) {
		set(DESCRIPTION, description);
	}

	public void setId(Long id) {
		set(ID, id);
	}

	public void setName(String name) {
		set(NAME, name);
	}

	public void setUri(String uri) {
		set(URI, uri);
	}
	
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof KBInfoModel) {
			KBInfoModel o = (KBInfoModel) obj;
			return getId().equals(o.getId());
		}
		return false;
	}


}
